package sharedjplaylist.server.service;

import java.util.ArrayList;

import org.slim3.datastore.Datastore;

import sharedjplaylist.client.service.PlaylistService;
import sharedjplaylist.server.meta.PlaylistMeta;
import sharedjplaylist.shared.model.Playlist;

import com.google.appengine.api.datastore.Key;

public class PlaylistServiceImpl implements PlaylistService {

    PlaylistMeta query = PlaylistMeta.get();

    public void setPlaylist(Playlist playlist){
        Datastore.put(playlist);
    }

    public ArrayList<Playlist> getPlaylistList(){
        return (ArrayList<Playlist>) Datastore.query(query).sort(query.datetime.desc).asList();
    }

    public void deletePlaylist(Key key){
        Datastore.delete(key);
    }
}
